﻿// =================================================================== 
// 数据实体层(GDIT.Model)实体映射
//====================================================================
// 文件：Mtb_PicType.cs
// 项目名称：学院网站
// 创建时间：2012-08-08
// 负责人：ChenZhiGang
// 引用DevExpress.Xpo程序集
// 程序集介绍：图片类型分类实体类（轮换图片，重大信息，链接图片）
// ===================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.Xpo;

namespace GDIT.Model
{
    public class Mtb_PicType : PersistentClass
    {
        public Mtb_PicType()
        : base()
    {
        this.Modified = false;
    }

        public Mtb_PicType(Session theSession)
        : base(theSession)
    {
        this.Modified = false;
    }

    private string _typeName = string.Empty;
    /// <summary>
    ///图片类型名称
    /// </summary>
    [DbType("varchar(50)")]
    public string TypeName
    {
        get { return _typeName; }
        set
        {
            if (_typeName != value)
            {
                _typeName = value;
                if (!IsLoading) { this.Modified = true; }
            }
        }
    }

    /// <summary>
    /// 图片类型所属的图片信息
    /// </summary>
    [Association("PicTypeInfos", typeof(Mtb_PicInfo))]
    public XPCollection Infos 
    {
        get 
        {
            return GetCollection("Infos"); 
        }
    }

    /// <summary>
    /// 图片类型所属的风貌图片信息
    /// </summary>
    [Association("PicTypeSceneryPicInfos", typeof(Mtb_SceneryPicInfo))]
    public XPCollection SceneryInfos
    {
        get
        {
            return GetCollection("SceneryInfos");
        }
    }


    /// <summary>
    /// 防止编辑后马上保存
    /// </summary>
    protected override void EndEdit()
    {
        return;
    }

    /// <summary>
    /// 检验数据
    /// </summary>
    /// <returns></returns>
    public override string GetDataError()
    {
        if (this._typeName.Trim().Length == 0) { return string.Format("图片类型名称不能为空"); }
        return "";
    }
    }
}
